Skip to content

feat(cicero-core): detect legacy runtime@0.2.0 types alongside 1.0 - #950

Draft
mttrbrts wants to merge 3 commits into
claude/runtime-1.0-namespace-supportfrom
claude/agreement-1.0-dual-runtime
Draft

mttrbrts wants to merge 3 commits into
claude/runtime-1.0-namespace-supportfrom
claude/agreement-1.0-dual-runtime

Conversation

@mttrbrts

@mttrbrts mttrbrts commented Oct 1, 2026

Copy link
Copy Markdown
Member

Stacked on #946

This builds on #946 (feat(cicero-core)!: require the 1.0 runtime models) and targets its branch.

#946 moves getRequestTypes / getResponseTypes / getEmitTypes / getStateTypes / isStateful from org.accordproject.runtime@0.2.0 to the 1.0 models. On its own, that change breaks every template that still models its runtime types with runtime@0.2.0. In accordproject/cicero-template-library that is about 57 templates. They target cicero ^2.0.0, so they pass the version check, but they would then report no request, response, state or emit types. These templates have to keep working with the next cicero-core, next to new templates on the 1.0 models.

This PR also lets a template that composes other templates say which TemplateData subtype is its own template model.

Changes

  • Dual runtime lookups (packages/cicero-core/src/template.ts)
    • Adds LEGACY_REQUEST_TYPE, LEGACY_RESPONSE_TYPE, LEGACY_EMIT_TYPE and LEGACY_STATE_TYPE (org.accordproject.runtime@0.2.0.{Request,Response,Obligation,State}), documented next to feat(cicero-core)!: require the 1.0 runtime models #946's constants.
    • The request, response, emit and state lookups return the concrete subtypes of both the 1.0 base type and the legacy base type. Duplicates are removed and the order is stable, with 1.0 types first. findConcreteSubclassNames still treats a namespace that is not loaded as contributing nothing.
    • isStateful() is true when the model declares a concrete subtype of templatedata@1.0.0.StateData or of runtime@0.2.0.State. The legacy State is a concrete empty asset, so it is excluded explicitly with excludeBaseType, as on main.
  • Naming the template model (accordproject.templateModel)
    • A template that composes others carries copies of their models, and each copy has its own concrete TemplateData subtype. For example, a licence that creates a composed late-payment clause's requests, or reads a schedule document's data. package.json may now name the template model: "accordproject": { "templateModel": "<fully qualified name>" }.
    • Metadata#getTemplateModelName() returns the name, or undefined when the key is absent. Metadata rejects a value that is not a non-empty string. createTargetMetadata deep-copies package.json, so the key is kept there and through archive round-trips. Both are tested.
    • getTemplateModel() resolves the model in this order:
      1. the named type, if templateModel is set. It throws if the type is not found, or if it is not a concrete subtype of TemplateData or (for legacy templates) a concrete type with @template;
      2. the one concrete TemplateData subtype;
      3. if there are several, the existing "multiple" error, which now also suggests accordproject.templateModel;
      4. if there are none, the @template fallback, unchanged.
  • Tests (test/template.test.ts, test/metadata.test.ts)
    • New fixture legacy-runtime-cicero2: a cicero ^2.0.0 template on runtime@0.2.0 with a request, a response, a State subtype and an Obligation subtype. It is shaped like the cicero-template-library templates, and it reports all of those types and isStateful() === true.
    • 1.0 template (helloemit): reports its 1.0 types and isStateful() === true. no-template-decorator loads StateData but declares no subtype of it, so isStateful() === false.
    • feat(cicero-core)!: require the 1.0 runtime models #946's no-runtime-namespace tests still cover the case where neither runtime namespace is loaded (empty lists and false).
    • New fixture composed-template-model: a licence model plus a copy of a late-payment model, giving two TemplateData subtypes, with templateModel set. The tests check that:
      • the named model is picked, including after an archive round-trip;
      • without the key it still throws, and the error mentions accordproject.templateModel;
      • a missing type, a type in a namespace that is not loaded, a non-template type and the abstract TemplateData are each rejected;
      • a named legacy @template type is accepted.

Flags

  • feat(cicero-core)!: require the 1.0 runtime models #946's legacy-runtime fixture targets cicero ^1.0.0, so the version check still rejects it before any runtime lookup runs. That is why this PR adds legacy-runtime-cicero2 instead of reusing it. The fixture's description ("rather than silently loading with no runtime types") is now a little out of date. I left it as is.
  • For a legacy template, getStateTypes() includes the concrete base runtime@0.2.0.State, as it did on main. isStateful() excludes it.
  • Test results. Run with npm ci, then npm test -w @accordproject/cicero-core (lint, license check, build, jest): 193 passed, 5 failed, 2 skipped, and the templatelibrary suite fails to run.
    • Same failures on feat(cicero-core)!: require the 1.0 runtime models #946's head (cff6a1a) without this change: 169 passed, 5 failed, 2 skipped, with the same failing tests and suite.
    • Network only, because the sandbox gets a 403/405 from the proxy:
      • should create a template from a directory and download external models by default (models.accordproject.org);
      • the templatelibrary suite (templates.accordproject.org). Jest's worker then crashes serialising the circular axios error.
    • Not network, and present before this change: four hash assertions fail with different hashes. These are should roundtrip a template with a logo, … a source template (CR), … a compiled template (JavaScript) and #getHash. They may come from the merge of main into feat(cicero-core)!: require the 1.0 runtime models #946, but I have not confirmed that.

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to master from fork:branchname

🤖 Generated with Claude Code

https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS


Generated by Claude Code

claude added 3 commits October 1, 2026 18:45
The request, response, emit and state type lookups now report the
concrete subtypes of both the 1.0 base types and the legacy
org.accordproject.runtime@0.2.0 ones (Request, Response, Obligation,
State), de-duplicated, 1.0 types first. Base types whose namespace is not
loaded still contribute nothing.

isStateful() is true when the model declares a concrete subtype of
templatedata@1.0.0.StateData or of runtime@0.2.0.State. The legacy State
is a concrete empty asset, so it is excluded explicitly, as before 1.0.

Most templates in cicero-template-library target cicero ^2.0.0 but still
model their runtime types with runtime@0.2.0, and must keep working
alongside templates on the 1.0 models.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
A template that composes other templates carries copies of their
models, each with its own concrete subtype of TemplateData, so finding
the template model as the one TemplateData subtype is ambiguous.

package.json may now name it with accordproject.templateModel, exposed
as Metadata#getTemplateModelName(). getTemplateModel() returns the named
type when set, and throws if it is missing or is not a concrete subtype
of TemplateData (or, for legacy templates, a concrete type with
@template). Otherwise it resolves as before: the one concrete
TemplateData subtype, an error if there are several (which now suggests
accordproject.templateModel), or the @template decorator if there are
none.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
getRequestTypes, getResponseTypes, getEmitTypes and getStateTypes were
emitted in lib/template.d.ts as returning unknown[], because the new
findConcreteSubclassNamesOfAny helper de-duplicates through a Set of an
untyped array. That broke consumers typed against string[], such as
template-engine's LLMExecutor (TS2322). Annotate the helper and the four
getters as string[].

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
mttrbrts pushed a commit to accordproject/cicero-template-library that referenced this pull request Oct 1, 2026
… API, as three templates

The prototype's local runtime is replaced by the released shape of the
design:

- Models: the 1.0.0 namespaces are refreshed from accordproject/models#205,
  which folds the prototype's proposal namespace (composition.cto) into
  agreement@1.0.0 (Clause with data and clauses, AgreementReference with a
  documentId), runtime@1.0.0 (AgreementState.states) and obligation@1.0.0
  (ObligationIssued). composition.cto is removed.
- Templates: the composed late payment clause and the licensed work
  schedule become sibling templates, late-payment-poc and
  licensed-work-schedule-poc, since cicero-core loads model/ and logic/
  recursively. The licence keeps copies of their models, which its logic
  uses, and names its template model in package.json
  (accordproject.templateModel).
- Logic imports defineLogic from @accordproject/template-engine/logic and
  its factories from logic/generated/types.ts, which template-engine-codegen
  writes with Concerto's interfaces (npm run compile). runtime/ and
  scripts/generate-types.js are removed.
- Tests use @accordproject/template-engine/testing, and the agreement tests
  run on template-engine's AgreementProcessor, which compiles and loads each
  template's logic. Without a direct concerto-core import, the vitest alias
  around concerto-core's ESM version is no longer needed.
- The library depends on template-engine and cicero-core from the dist
  branches of accordproject/template-engine#187 and
  accordproject/template-archive#950, so the render suite loads, drafts,
  initialises and triggers all three templates; the expectedLoadFailures
  entry is removed.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed.

@github-actions github-actions Bot added the Stale label Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants